<span page-title ng-model="contentView">{{ 'Content Views for Composite Content View:' | translate }} {{ contentView.name }}</span>

<h3 translate>
  Content Views for {{ contentView.name }}
</h3>

<div data-extend-template="layouts/partials/table.html">
  <div data-block="list-actions">
    <button type="button" class="btn btn-default fr"
            ng-hide="denied('edit_content_views', contentView)"
            ng-disabled="table.numSelected === 0"
            ng-click="removeContentViewComponents()">
      <span translate>Remove Content Views</span>
    </button>
  </div>

  <span data-block="no-rows-message" translate>
    No Content Views belong to {{ contentView.name }}.  Use the add tab to add Content Views.
  </span>

  <span data-block="no-search-results-message" translate>
    No Content Views match the search.
  </span>

  <div data-block="table">
    <table class="table table-bordered table-striped">
      <thead>
        <tr bst-table-head row-select>
          <th bst-table-column translate>Name</th>
          <th bst-table-column translate>Version</th>
          <th bst-table-column translate>Environment</th>
          <th bst-table-column translate>Description</th>
          <th bst-table-column translate>Content</th>
        </tr>
      </thead>

      <tbody>
        <tr bst-table-row ng-repeat="contentViewComponent in table.rows" row-select="contentViewComponent">
          <td bst-table-cell>{{ contentViewComponent.content_view.name }}</td>
          <td bst-table-cell ng-init="contentViewComponent.versionId = getVersionId(contentViewComponent)">
            <span bst-edit-select="contentViewComponent.versionId"
                  display-value="getVersionString(contentViewComponent)"
                  display-value-default="getVersionString(contentViewComponent)"
                  readonly="denied('edit_content_views', contentView)"
                  selector="contentViewComponent.versionId"
                  options="getAvailableVersions(contentViewComponent.content_view)"
                  options-format="option.id as option.version for option in options | orderBy: '-id'"
                  on-save="saveContentViewComponent(contentViewComponent)"
                  ng-if="contentViewComponent.content_view.version_count > 0">
            </span>
            <div  ng-if="contentViewComponent.content_view.version_count > 0" ng-show="(!contentViewComponent.latest) && contentViewComponent.content_view_version.version != contentViewComponent.content_view.latest_version" translate>
                A newer version is available: {{ contentViewComponent.content_view.latest_version }}
            </div>
            <div ng-if="contentViewComponent.content_view.version_count === 0 " translate>
                Latest (Currently no version)
            </div>
          </td>
          <td bst-table-cell>
          <span ng-show="contentViewComponent.content_view_version.environments.length !== 0"
                ng-repeat="environment in contentViewComponent.content_view_version.environments">
            {{ environment.name }}<span ng-if="!$last">, </span>
          </span>
          <span ng-show="contentViewComponent.content_view.version_count === 0 || contentViewComponent.content_view_version.environments.length === 0" translate>
            Not yet published
          </span>
          </td>
          <td bst-table-cell>{{ contentViewComponent.content_view.description }}</td>
          <td bst-table-cell>
            <div>
              <a ui-sref="content-view.repositories.yum.list({contentViewId: contentViewComponent.content_view.id})" translate>
                {{ contentViewComponent.content_view_version.repositories.length || 0 }} Repositories
              </a>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>


